<template>
  <div>
    <h1>A组件</h1>
    <input
      v-model="inputValue"
      placeholder="输入要传递的内容"
    />
    <button @click="goToB">跳转到B组件并传值</button>
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import { setCachedData } from "@/utils/eventBus";

const inputValue = ref("");
const router = useRouter();

const goToB = () => {
  setCachedData(inputValue.value); // 缓存数据并发事件
  router.push({ name: "w32" }); // 跳转到B组件路由
};
</script>
